<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>文章</title>
	<link rel="stylesheet" href="css/vant.css">
	<link rel="stylesheet" href="css/shareForum.css">
	<link rel="stylesheet" href="css/conmask.css">
</head>

<body>
	<div id="app" v-cloak>
		<div class="forumHeader">
			<div class="forumTitle">
				{{forum.forum_title}}
			</div>
			<div class="info">
				值班长客服 <span>{{forum.date_time}}</span>
			</div>
			<div class="tuijian">
				好文推荐 <span>·</span> <span>精选</span>
			</div>
		</div>
		<!-- 文章内容 开始 -->
		<img v-lazy="path + 'luntan/' + forum.forum_img" class="page-img">
		<img v-for="item in forumImgs" v-lazy="path + 'luntan/' + item.imgName" class="page-img">
		<!-- 文章内容 结束 -->

		<!-- 评论区 开始 -->
		<div class="commentBox">
			<div class="comTit">精彩评论</div>
			<div class="comItem" v-for="(item,index) in  comments" :key="index">
				<img :src="item.city_name" alt="" class="userImg" @error="loadimg">
				<div class="itemTop">
					<div class="topLeft">
						<div>{{item.user_name}}</div>
						<div>{{item.date_time}}</div>
					</div>
					<div class="topRight">
						<van-icon name="star" color="#FF3B14" class="star" />
						<van-icon name="star" color="#FF3B14" class="star" />
						<van-icon name="star" color="#FF3B14" class="star" />
						<van-icon name="star" color="#FF3B14" class="star" />
						<van-icon name="star" color="#FF3B14" class="star" />
					</div>
				</div>
				<div class="itemBottom">
					{{item.comment_content}}
				</div>
			</div>
		</div>

		<!-- 评论区 结束 -->

		<!-- 按钮 -->
		<div class="btn" @click="downHandle">
			下载APP查看
		</div>
		<div class="topicBtn1" @click="toShare">
			分享
		</div>
		<div class="downBox" v-if="showPop" @click="showPop=false">
			<img src="./img/downTip.png" alt="">
		</div>
		<div class="downBox" v-if="sharePop" @click="sharePop=false">
			<img class="shareImg" src="./img/shareImg.png" alt="">
		</div>

		<div class="mask" v-if="mask">
			<img src="img/load.gif">
		</div>
	</div>


	<script src="js/vue.min.js"></script>
	<script src="js/flex_ible/lib-flexible.js"></script>
	<script src="js/vue-lazyload.js"></script>
	<script src="js/vant.min.js"></script>
	<script src="js/vue-lazyload.js"></script>
	<script src="js/url.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/ajax.js"></script>
	<script type="text/javascript" src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
	<script>
		var ua = navigator.userAgent.toLowerCase();
		var isWeixin = ua.indexOf('micromessenger') != -1;
		if (!isWeixin) {
			window.location.href = 'https://zbz-downlink.oss-cn-zhangjiakou.aliyuncs.com/com.ccclkj.clinic.wgt'
		}

		console.log(ua);
		console.log(isWeixin);
		Vue.use(VueLazyload);
		var vm = new Vue({
			el: "#app",
			data: {
				mask: false,
				forum_id: sessionStorage.getItem('forumId'),
				user_id: sessionStorage.getItem('userId'),
				forum: {},
				comments: [],
				forumImgs: [],
				showPop: false,
				sharePop: false,
			},
			created() {
				if (!this.forum_id) {
					window.location.replace("./newDown.html")
				}
				this.getData()
			},
			methods: {
				downHandle: function () {
					window.location.replace("newDown.html")
					return;

					if (isWeixin) {
						this.showPop = true

					} else {
						if (window.navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
							console.log("000");
							var loadDateTime = new Date();
							window.location = "clinic://"; //schema链接或者universal link
							window.setTimeout(
								function () { //如果没有安装app,便会执行setTimeout跳转下载页
									var timeOutDateTime = new Date();
									if (timeOutDateTime - loadDateTime < 5000) {
										window.location =
											"https://itunes.apple.com/cn/app/%E5%80%BC%E6%97%A5%E7%94%9F/id1448441059?mt=8"; //ios下载地址  
									} else {
										window.close();
									}
								}, 500);

						} else if (window.navigator.userAgent.match(/android/i)) {
							var state = null;
							try {

								window.location = 'clinic://'; //schema链接或者universal link
								window.setTimeout(
									function () {
										window.location =
											"https://a.app.qq.com/o/simple.jsp?pkgname=com.ccclkj.clinic";

										//window.location = "http://www.ccclkj.cn:1125/zbz.apk"; 
										//android下载地址  
									}, 500);
							} catch (e) { }
						}

					}
				},
				loadimg(e) {
					var img = e.srcElement;
					img.src = 'img/about.png'
				},
				getData: function () {
					var that = this;
					console.log(sessionStorage.getItem('forumId'))
					console.log(sessionStorage.getItem('user_id'))
					ajax({
						type: "post",
						url: newUrl + "community/getForumComment",
						data: {
							user_id: that.user_id,
							forum_id: that.forum_id,
						},
						dataType: 'json',
						timeout: 10000,
						contentType: "application/json",
						success: function (res) {
							var res = JSON.parse(res)
							if (res.flag) {
								var data = res.data
								that.forum = data.forum
								if (data.comments.length > 5) {
									that.comments = data.comments.slice(0, 5)
								} else {
									that.comments = data.comments.slice(0, data.comments.length)
								}
								that.forumImgs = data.forumImgs
							}
						},
					})
				},
				toShare: function () {
					var _this = this;
					_this.mask = true;
					var title = _this.forum.forum_title;
					var dec = "这里有好文章，分享给你咯";
					var url = location.href.split('#')[0];
					ajax({
						type: "post",
						url: newUrl + "share/share",
						data: {
							url: url
						},
						dataType: 'json',
						timeout: 10000,
						contentType: "application/json",
						success: function (data) {
							var res = JSON.parse(data)
							console.log(res)
							_this.mask = false
							var datas = res.data
							wx.config({
								debug: false,
								appId: datas.appId,
								timestamp: datas.timestamp,
								nonceStr: datas.nonceStr,
								signature: datas.sign,
								jsApiList: [
									'checkJsApi',
									'updateAppMessageShareData',
									'updateTimelineShareData',
									'onMenuShareTimeline',
									'onMenuShareAppMessage'
								]
							});
							wx.ready(function () { //需在用户可能点击分享按钮前就先调用
								_this.sharePop = true;
								var img = path + "luntan/" + _this.forum.forum_img;
								var link_rrl =
									"https://www.ccclkj.cn/sharepage/index.html?user_id=" +
									_this.user_id + "&id=" + _this.forum_id + "&flag=1&shopId=" + sessionStorage.shopId
								wx.updateAppMessageShareData({
									title: title, // 分享标题
									desc: dec, // 分享描述
									link: link_rrl, // 分享链接
									imgUrl: img, // 分享图标
									type: 'link', // 分享类型,music、video或link，不填默认为link
									success: function () {
										//$("body").remove(".thisMask");
										return false;
									}
								})
								wx.updateTimelineShareData({
									title: title, // 分享标题
									link: link_rrl, // 分享链接
									imgUrl: img, // 分享图标
									success: function () {
										//$("body").remove(".thisMask");
										return false;
									}
								})
							});
						}
					})
				},
			}
		})
	</script>

</body>

</html>